package com.lglbc.kafka;


import lombok.extern.slf4j.Slf4j;
import org.apache.kafka.clients.consumer.ConsumerRecord;
import org.springframework.kafka.annotation.KafkaListener;
import org.springframework.kafka.support.Acknowledgment;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class KafkaConsumer {
    private final String topic = "topic_test";
    @KafkaListener(topics = topic, groupId = "group.springboot")
    public void topicListener(ConsumerRecord<String, String> record, Acknowledgment item) {
        log.info("消费消息：{}==,{}==,{};",record.topic(),record.partition(),record.value());
        //手动提交
        item.acknowledge();
    }
}
